package chuangyi.com.org.ViewModel;

import android.content.Context;
import android.databinding.Bindable;
import android.view.View;

import java.util.Date;

import chuangyi.com.org.DOMIHome.BR;
import chuangyi.com.org.DOMIHome.HomeActivity;
import chuangyi.com.org.DOMIHome.LoadingDialog;
import chuangyi.com.org.DOMIHome.Utils.WebApi;
import chuangyi.com.org.DOMIHome.adapter.ListBindingAdapter;

/**
 * Created by zxh on 16/11/25.
 */

public class CollectVideoItem extends VideoItem {
//    视频id:videoid,标题：videoname，简介:videodesc,
//    收藏时期:collecttime,browser:浏览数,collectcoun:收藏数, collectid:收藏id
    private int browser;
    private int collectcoun;
    private int collectid;
    private Date collecttime;
    @Bindable
    public int getBrowser() {
        return browser;
    }

    public void setBrowser(int browser) {
        this.browser = browser;
        notifyPropertyChanged(BR.browser);
    }

    @Bindable
    public Date getCollecttime() {
        return collecttime;
    }

    public void setCollecttime(Date collecttime) {
        this.collecttime = collecttime;
    }

    @Bindable
    public int getCollectcoun() {
        return collectcoun;
    }

    public void setCollectcoun(int collectcoun) {
        this.collectcoun = collectcoun;
        notifyPropertyChanged(BR.collectcoun);
    }

    public int getCollectid() {
        return collectid;
    }

    public void setCollectid(int collectid) {
        this.collectid = collectid;
    }

    public CollectVideoItem(Context context, int layoutId){
        super(context, layoutId);
    }

    public void onClickDelete(View view){
        LoadingDialog.getInstance(getContext()).show();
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(WebApi.removeCollection(getContext(), "v", getVideoid()) != -1){
                    HomeActivity.notifyListChange(ListBindingAdapter.ACTION_DEL, CollectVideoItem.this);
                }
                LoadingDialog.getInstance(getContext()).dismiss();
            }
        }).start();
    }
}
